<% if @invit!=[] %>
<h2>Invitations</h2>

<% for i in @invit %>
<div id="inv<%=i.id%>">
<%=i.name%> invites you to join <%=i.project.name%>
<%= link_to_remote( "Accept", {:update => "inv"+i.id.to_s, :url =>{ :controller=> :invitation, :action => :accept, :id=>i.id },
 :loading  => visual_effect('appear', 'ind'+i.id.to_s),
 :success => {visual_effect('fade', 'ind'+i.id.to_s), visual_effect('fade','ind'+i.id.to_s)}},
 {:class=>"btnlnk"}) %>
<%= link_to_remote( "Decline", {:update => "inv"+i.id.to_s, :url =>{ :controller=> :invitation, :action => :decline, :id=>i.id },
 :loading  => visual_effect('appear', 'ind'+i.id.to_s),
 :success => {visual_effect('fade', 'ind'+i.id.to_s), visual_effect('fade','ind'+i.id.to_s)}},
 {:class=>"btnlnk"}) %>

<img id="ind<%=i.id%>" src="/images/loading.gif" style="display:none;">

</div>
<% end %>

<% end %>
<h2>Dashboard</h2>
<% if @projects.size == 0 -%>
Welcome.<br/>
You can now keep track of the tasks you have to do. They will belong to categories called "projects".<br/>
Each project can have its own group of users.<br/>
<br/>
Create a task now by clicking on tasks, in the menu above.<br/>

<% else -%>

<h3>Important tasks</h3>
<% if @important_tasks.size==0 -%>
You have no tasks.
<% else -%>
<ul class="mylist">
<% for task in @important_tasks -%>
<li><div class="priority p<%=task.priority%>"><%= task.priority %></div><%= task.title %> <% if task.project != nil %>(<a href="/task/select_project_index/<%=task.project.id%>"><%= task.project.name %>)<%end%></a></li>
<% end -%>
</ul>
<% end -%>

<h3>All your projects with 5 important active tasks assigned to you</h3>
<p>Click on a project name to see all the tasks to do for this project.</p>
<%
@projects.each { |p|%>

	<h4><%= link_to(p.name.upcase, {:controller => 'task', :action => 'select_project_index', :id => p.id})  %> <%=Task.count :all, :conditions=>"done='0' and project_id=#{p.id}"%> tasks</h4>
	<% tasks = p.tasks.find(:all, :conditions=>["done='0' and user_id='#{session['user']['id']}' and title!=''"], :order => "priority, `order`", :limit => 5) -%>
	
	<% if(tasks.size==0) -%>
	(no task for you)<br/>
	<% else -%>
	<ul class="mylist">
	<% for task in tasks -%>
	<li><%= task.title %></li>
	<% end -%>
	</ul>
	<% end -%>
<%	} # each project

end # if one project exists
-%>
